package com.nexgo.payment.trans.setting.base;

import android.os.Bundle;
import android.view.Gravity;

import com.nexgo.payment.R;
import com.nexgo.payment.databases.Repository;
import com.nexgo.payment.fragment.ProgressDialogFragment;
import com.nexgo.payment.fragment.TextDialogFragment;
import com.nexgo.payment.ui.BaseActivity;
import com.nexgo.payment.widget.TitleBuilder;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import butterknife.ButterKnife;

/**
 * 交易详情界面
 *
 * @author 谭忠扬-YuriTam
 * @time 2017年8月14日
 */
public class ResetBaseActivity extends BaseActivity implements ResetBaseContract.View {
    private Logger log = LoggerFactory.getLogger(ResetBaseActivity.class.getSimpleName());
    private ResetBasePresenter mPresenter;
    private ProgressDialogFragment mWaitDialogFragment;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_download_trans);
        ButterKnife.bind(this);
        new TitleBuilder(this).gone();
        new ResetBasePresenter(this, Repository.getInstance());
    }

    /**
     * 初始化视图
     */
    private void initView() {
        new TitleBuilder(this)
                .setExternalTitleBgRes(R.drawable.bg_blue_icon)
                .setLeftImage(R.drawable.arrow_icon)
                .setTitleText(getString(R.string.reset_base_location))
                .build();
    }

    @Override
    protected void onResume() {
        super.onResume();
        mPresenter.start();
    }


    @Override
    public void setPresenter(ResetBasePresenter presenter) {
        this.mPresenter = presenter;
    }

    @Override
    public void showTransResult(boolean success) {
        TextDialogFragment dialogFragment = TextDialogFragment.newInstance();
        if(success)
            dialogFragment.setDialogType(TextDialogFragment.DIALOG_TYPE_SUCCESS);
        else
            dialogFragment.setDialogType(TextDialogFragment.DIALOG_TYPE_WRONG);
        dialogFragment.setContentText(getString(R.string.reset_base_location) + (success? getString(R.string.success):getString(R.string.fail)), Gravity.CENTER);
        dialogFragment.setPositionText(getString(R.string.confirm));
        dialogFragment.setDialogListener(new TextDialogFragment.OnDialogListener() {
            @Override
            public void onCancel() {
                finish();
            }

            @Override
            public void onConfirm() {
                finish();
            }
        });
        dialogFragment.show(getSupportFragmentManager(), null);
    }

}
